<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <textarea rows="10" cols="50" id="textarea">

    </textarea>
    <form  id="form" action="ai" method="post">
        <input type="text" name="sentence">
        <input id="userbutton" type="button" value="发送" >
    </form>
</body>
</html>

<script src="jquery/jquery.min.js"></script>
<script type="text/javascript">
    console.log("进入ajax");
    $("#userbutton").click(function(){
        console.log("进入ajax");
       var targertUrl = $("#form").attr("action");
       var formData = $("#form").serialize();
       $.ajax({
			type:'post',
			url:targertUrl,
			cache:false,
			data:formData,
			dataType:'json',
			success:function(data){
				$("#textarea").html(data.user);
			},
			error:function(){
				alert("失败");
			}
		})
	})
</script>